0 CpxTRS
↳1 NestedDefinedSymbolProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxTRS
↳3 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxWeightedTrs
↳5 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳6 CpxTypedWeightedTrs
↳7 CompletionProof (UPPER BOUND(ID), 9 ms)
↳8 CpxTypedWeightedCompleteTrs
↳9 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳10 CpxRNTS
↳11 CompleteCoflocoProof (⇔, 605 ms)
↳12 BOUNDS(1, n^3)
minus(x, 0) → x
minus(0, y) → 0
minus(s(x), s(y)) → minus(p(s(x)), p(s(y)))
minus(x, plus(y, z)) → minus(minus(x, y), z)
p(s(s(x))) → s(p(s(x)))
p(0) → s(s(0))
div(s(x), s(y)) → s(div(minus(x, y), s(y)))
div(plus(x, y), z) → plus(div(x, z), div(y, z))
plus(0, y) → y
plus(s(x), y) → s(plus(y, minus(s(x), s(0))))
p(0) → s(s(0))
minus(s(x), s(y)) → minus(p(s(x)), p(s(y)))
plus(s(x), y) → s(plus(y, minus(s(x), s(0))))
div(s(x), s(y)) → s(div(minus(x, y), s(y)))
plus(0, y) → y
minus(x, 0) → x
p(s(s(x))) → s(p(s(x)))
minus(0, y) → 0
p(0) → s(s(0)) [1]
minus(s(x), s(y)) → minus(p(s(x)), p(s(y))) [1]
plus(s(x), y) → s(plus(y, minus(s(x), s(0)))) [1]
div(s(x), s(y)) → s(div(minus(x, y), s(y))) [1]
plus(0, y) → y [1]
minus(x, 0) → x [1]
p(s(s(x))) → s(p(s(x))) [1]
minus(0, y) → 0 [1]
p(0) → s(s(0)) [1]
minus(s(x), s(y)) → minus(p(s(x)), p(s(y))) [1]
plus(s(x), y) → s(plus(y, minus(s(x), s(0)))) [1]
div(s(x), s(y)) → s(div(minus(x, y), s(y))) [1]
plus(0, y) → y [1]
minus(x, 0) → x [1]
p(s(s(x))) → s(p(s(x))) [1]
minus(0, y) → 0 [1]
p :: 0:s → 0:s 0 :: 0:s s :: 0:s → 0:s minus :: 0:s → 0:s → 0:s plus :: 0:s → 0:s → 0:s div :: 0:s → 0:s → 0:s |
p(v0) → null_p [0]
div(v0, v1) → null_div [0]
minus(v0, v1) → null_minus [0]
plus(v0, v1) → null_plus [0]
null_p, null_div, null_minus, null_plus
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
0 => 0
null_p => 0
null_div => 0
null_minus => 0
null_plus => 0
div(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
div(z, z') -{ 1 }→ 1 + div(minus(x, y), 1 + y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
minus(z, z') -{ 1 }→ x :|: x >= 0, z = x, z' = 0
minus(z, z') -{ 1 }→ minus(p(1 + x), p(1 + y)) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
minus(z, z') -{ 1 }→ 0 :|: y >= 0, z = 0, z' = y
minus(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
p(z) -{ 0 }→ 0 :|: v0 >= 0, z = v0
p(z) -{ 1 }→ 1 + p(1 + x) :|: x >= 0, z = 1 + (1 + x)
p(z) -{ 1 }→ 1 + (1 + 0) :|: z = 0
plus(z, z') -{ 1 }→ y :|: y >= 0, z = 0, z' = y
plus(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
plus(z, z') -{ 1 }→ 1 + plus(y, minus(1 + x, 1 + 0)) :|: x >= 0, y >= 0, z = 1 + x, z' = y
eq(start(V, V1),0,[p(V, Out)],[V >= 0]). eq(start(V, V1),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[plus(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1),0,[div(V, V1, Out)],[V >= 0,V1 >= 0]). eq(p(V, Out),1,[],[Out = 2,V = 0]). eq(minus(V, V1, Out),1,[p(1 + V2, Ret0),p(1 + V3, Ret1),minus(Ret0, Ret1, Ret)],[Out = Ret,V1 = 1 + V3,V2 >= 0,V3 >= 0,V = 1 + V2]). eq(plus(V, V1, Out),1,[minus(1 + V5, 1 + 0, Ret11),plus(V4, Ret11, Ret12)],[Out = 1 + Ret12,V5 >= 0,V4 >= 0,V = 1 + V5,V1 = V4]). eq(div(V, V1, Out),1,[minus(V6, V7, Ret10),div(Ret10, 1 + V7, Ret13)],[Out = 1 + Ret13,V1 = 1 + V7,V6 >= 0,V7 >= 0,V = 1 + V6]). eq(plus(V, V1, Out),1,[],[Out = V8,V8 >= 0,V = 0,V1 = V8]). eq(minus(V, V1, Out),1,[],[Out = V9,V9 >= 0,V = V9,V1 = 0]). eq(p(V, Out),1,[p(1 + V10, Ret14)],[Out = 1 + Ret14,V10 >= 0,V = 2 + V10]). eq(minus(V, V1, Out),1,[],[Out = 0,V11 >= 0,V = 0,V1 = V11]). eq(p(V, Out),0,[],[Out = 0,V12 >= 0,V = V12]). eq(div(V, V1, Out),0,[],[Out = 0,V13 >= 0,V14 >= 0,V = V13,V1 = V14]). eq(minus(V, V1, Out),0,[],[Out = 0,V15 >= 0,V16 >= 0,V = V15,V1 = V16]). eq(plus(V, V1, Out),0,[],[Out = 0,V17 >= 0,V18 >= 0,V = V17,V1 = V18]). input_output_vars(p(V,Out),[V],[Out]). input_output_vars(minus(V,V1,Out),[V,V1],[Out]). input_output_vars(plus(V,V1,Out),[V,V1],[Out]). input_output_vars(div(V,V1,Out),[V,V1],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. recursive : [p/2]
1. recursive : [minus/3]
2. recursive : [ (div)/3]
3. recursive : [plus/3]
4. non_recursive : [start/2]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into p/2
1. SCC is partially evaluated into minus/3
2. SCC is partially evaluated into (div)/3
3. SCC is partially evaluated into plus/3
4. SCC is partially evaluated into start/2
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations p/2
* CE 8 is refined into CE [18]
* CE 6 is refined into CE [19]
* CE 7 is refined into CE [20]
### Cost equations --> "Loop" of p/2
* CEs [20] --> Loop 13
* CEs [18] --> Loop 14
* CEs [19] --> Loop 15
### Ranking functions of CR p(V,Out)
* RF of phase [13]: [V-1]
#### Partial ranking functions of CR p(V,Out)
* Partial RF of phase [13]:
- RF of loop [13:1]:
V-1
### Specialization of cost equations minus/3
* CE 10 is refined into CE [21]
* CE 11 is refined into CE [22]
* CE 12 is refined into CE [23]
* CE 9 is refined into CE [24,25,26,27]
### Cost equations --> "Loop" of minus/3
* CEs [27] --> Loop 16
* CEs [26] --> Loop 17
* CEs [25] --> Loop 18
* CEs [24] --> Loop 19
* CEs [21] --> Loop 20
* CEs [22,23] --> Loop 21
### Ranking functions of CR minus(V,V1,Out)
* RF of phase [16]: [V-1,V1-1]
#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [16]:
- RF of loop [16:1]:
V-1
V1-1
### Specialization of cost equations (div)/3
* CE 17 is refined into CE [28]
* CE 16 is refined into CE [29,30,31]
### Cost equations --> "Loop" of (div)/3
* CEs [31] --> Loop 22
* CEs [30] --> Loop 23
* CEs [29] --> Loop 24
* CEs [28] --> Loop 25
### Ranking functions of CR div(V,V1,Out)
* RF of phase [22]: [V/2-1]
* RF of phase [24]: [V]
#### Partial ranking functions of CR div(V,V1,Out)
* Partial RF of phase [22]:
- RF of loop [22:1]:
V/2-1
* Partial RF of phase [24]:
- RF of loop [24:1]:
V
### Specialization of cost equations plus/3
* CE 15 is refined into CE [32]
* CE 14 is refined into CE [33]
* CE 13 is refined into CE [34,35]
### Cost equations --> "Loop" of plus/3
* CEs [35] --> Loop 26
* CEs [34] --> Loop 27
* CEs [32] --> Loop 28
* CEs [33] --> Loop 29
### Ranking functions of CR plus(V,V1,Out)
* RF of phase [26,27]: [V+V1]
#### Partial ranking functions of CR plus(V,V1,Out)
* Partial RF of phase [26,27]:
- RF of loop [26:1]:
V+V1-1
- RF of loop [27:1]:
V+V1
### Specialization of cost equations start/2
* CE 2 is refined into CE [36,37,38]
* CE 3 is refined into CE [39,40,41]
* CE 4 is refined into CE [42,43,44]
* CE 5 is refined into CE [45,46,47,48,49]
### Cost equations --> "Loop" of start/2
* CEs [45] --> Loop 30
* CEs [39] --> Loop 31
* CEs [36,37,38,40,41,42,43,44,46,47,48,49] --> Loop 32
### Ranking functions of CR start(V,V1)
#### Partial ranking functions of CR start(V,V1)
Computing Bounds
=====================================
#### Cost of chains of p(V,Out):
* Chain [[13],14]: 1*it(13)+0
Such that:it(13) =< Out
with precondition: [Out>=1,V>=Out+1]
* Chain [15]: 1
with precondition: [V=0,Out=2]
* Chain [14]: 0
with precondition: [Out=0,V>=0]
#### Cost of chains of minus(V,V1,Out):
* Chain [[16],21]: 1*it(16)+1*s(5)+1*s(6)+1
Such that:aux(3) =< V
aux(5) =< V1
it(16) =< aux(5)
it(16) =< aux(3)
s(6) =< it(16)*aux(5)
s(5) =< it(16)*aux(3)
with precondition: [Out=0,V>=2,V1>=2]
* Chain [[16],19,21]: 1*it(16)+1*s(5)+1*s(6)+2
Such that:aux(3) =< V
aux(6) =< V1
it(16) =< aux(6)
it(16) =< aux(3)
s(6) =< it(16)*aux(6)
s(5) =< it(16)*aux(3)
with precondition: [Out=0,V>=2,V1>=2]
* Chain [[16],19,20]: 1*it(16)+1*s(5)+1*s(6)+2
Such that:aux(3) =< V
aux(7) =< V1
it(16) =< aux(7)
it(16) =< aux(3)
s(6) =< it(16)*aux(7)
s(5) =< it(16)*aux(3)
with precondition: [Out=0,V>=2,V1>=2]
* Chain [[16],18,21]: 1*it(16)+1*s(5)+1*s(6)+1*s(7)+2
Such that:aux(3) =< V
aux(8) =< V1
it(16) =< aux(8)
s(7) =< aux(8)
it(16) =< aux(3)
s(6) =< it(16)*aux(8)
s(5) =< it(16)*aux(3)
with precondition: [Out=0,V>=2,V1>=3]
* Chain [[16],17,21]: 1*it(16)+1*s(5)+1*s(6)+1*s(8)+2
Such that:aux(4) =< V1
aux(9) =< V
it(16) =< aux(9)
s(8) =< aux(9)
it(16) =< aux(4)
s(6) =< it(16)*aux(4)
s(5) =< it(16)*aux(9)
with precondition: [Out=0,V>=3,V1>=2]
* Chain [[16],17,20]: 1*it(16)+1*s(5)+1*s(6)+1*s(8)+2
Such that:aux(3) =< V
s(8) =< Out
aux(10) =< V1
it(16) =< aux(10)
it(16) =< aux(3)
s(6) =< it(16)*aux(10)
s(5) =< it(16)*aux(3)
with precondition: [V1>=2,Out>=1,V>=Out+2]
* Chain [21]: 1
with precondition: [Out=0,V>=0,V1>=0]
* Chain [20]: 1
with precondition: [V1=0,V=Out,V>=0]
* Chain [19,21]: 2
with precondition: [Out=0,V>=1,V1>=1]
* Chain [19,20]: 2
with precondition: [Out=0,V>=1,V1>=1]
* Chain [18,21]: 1*s(7)+2
Such that:s(7) =< V1
with precondition: [Out=0,V>=1,V1>=2]
* Chain [17,21]: 1*s(8)+2
Such that:s(8) =< V
with precondition: [Out=0,V>=2,V1>=1]
* Chain [17,20]: 1*s(8)+2
Such that:s(8) =< Out
with precondition: [V1>=1,Out>=1,V>=Out+1]
#### Cost of chains of div(V,V1,Out):
* Chain [[24],25]: 2*it(24)+0
Such that:it(24) =< Out
with precondition: [V1=1,Out>=1,V>=Out]
* Chain [[24],23,25]: 2*it(24)+2*s(47)+2*s(48)+5*s(49)+5*s(50)+5*s(51)+3
Such that:s(46) =< 1
s(45) =< V-Out+1
it(24) =< Out
s(47) =< s(45)
s(48) =< s(46)
s(49) =< s(46)
s(49) =< s(45)
s(50) =< s(49)*s(46)
s(51) =< s(49)*s(45)
with precondition: [V1=1,Out>=2,V>=Out]
* Chain [[22],25]: 3*it(22)+2*s(66)+1*s(67)+1*s(68)+1*s(69)+0
Such that:s(59) =< V
it(22) =< V/2
s(61) =< V1
aux(16) =< s(61)
aux(15) =< s(59)-2
aux(14) =< s(59)
s(71) =< it(22)*aux(16)
s(72) =< it(22)*aux(15)
s(70) =< it(22)*aux(14)
s(66) =< s(72)
s(67) =< s(71)
s(67) =< s(70)
s(68) =< s(67)*s(61)
s(69) =< s(67)*s(59)
with precondition: [V1>=2,Out>=1,V>=2*Out+1]
* Chain [[22],23,25]: 5*it(22)+2*s(48)+5*s(49)+5*s(50)+5*s(51)+2*s(66)+1*s(67)+1*s(68)+1*s(69)+3
Such that:aux(17) =< V
aux(18) =< V1
it(22) =< aux(17)
s(48) =< aux(18)
s(49) =< aux(18)
s(49) =< aux(17)
s(50) =< s(49)*aux(18)
s(51) =< s(49)*aux(17)
aux(16) =< aux(18)
aux(15) =< aux(17)-2
aux(14) =< aux(17)
s(71) =< it(22)*aux(16)
s(72) =< it(22)*aux(15)
s(70) =< it(22)*aux(14)
s(66) =< s(72)
s(67) =< s(71)
s(67) =< s(70)
s(68) =< s(67)*aux(18)
s(69) =< s(67)*aux(17)
with precondition: [V1>=2,Out>=2,V+1>=2*Out]
* Chain [25]: 0
with precondition: [Out=0,V>=0,V1>=0]
* Chain [23,25]: 2*s(47)+2*s(48)+5*s(49)+5*s(50)+5*s(51)+3
Such that:s(45) =< V
s(46) =< V1
s(47) =< s(45)
s(48) =< s(46)
s(49) =< s(46)
s(49) =< s(45)
s(50) =< s(49)*s(46)
s(51) =< s(49)*s(45)
with precondition: [Out=1,V>=1,V1>=1]
#### Cost of chains of plus(V,V1,Out):
* Chain [[26,27],29]: 15*it(26)+2*s(110)+1*s(111)+1*s(112)+1*s(113)+5*s(120)+5*s(121)+1
Such that:aux(24) =< 1
aux(27) =< V+V1
it(26) =< aux(27)
aux(22) =< aux(27)-1
aux(21) =< aux(27)
s(116) =< it(26)*aux(22)
s(114) =< it(26)*aux(21)
s(120) =< it(26)*aux(24)
s(121) =< it(26)*aux(21)
s(110) =< s(116)
s(111) =< aux(27)
s(111) =< s(114)
s(112) =< s(111)*aux(24)
s(113) =< s(111)*aux(27)
with precondition: [V>=1,V1>=0,Out>=1,V+V1>=Out]
* Chain [[26,27],28]: 15*it(26)+2*s(110)+1*s(111)+1*s(112)+1*s(113)+5*s(120)+5*s(121)+0
Such that:aux(24) =< 1
aux(28) =< V+V1
it(26) =< aux(28)
aux(22) =< aux(28)-1
aux(21) =< aux(28)
s(116) =< it(26)*aux(22)
s(114) =< it(26)*aux(21)
s(120) =< it(26)*aux(24)
s(121) =< it(26)*aux(21)
s(110) =< s(116)
s(111) =< aux(28)
s(111) =< s(114)
s(112) =< s(111)*aux(24)
s(113) =< s(111)*aux(28)
with precondition: [V>=1,V1>=0,Out>=1]
* Chain [29]: 1
with precondition: [V=0,V1=Out,V1>=0]
* Chain [28]: 0
with precondition: [Out=0,V>=0,V1>=0]
#### Cost of chains of start(V,V1):
* Chain [32]: 12*s(150)+6*s(154)+16*s(155)+16*s(156)+16*s(157)+30*s(167)+10*s(172)+10*s(173)+4*s(174)+2*s(175)+2*s(176)+2*s(177)+3*s(186)+2*s(194)+1*s(195)+1*s(196)+1*s(197)+2*s(211)+1*s(212)+1*s(213)+1*s(214)+3
Such that:s(165) =< 1
s(166) =< V+V1
s(186) =< V/2
aux(32) =< V
aux(33) =< V1
s(150) =< aux(32)
s(167) =< s(166)
s(168) =< s(166)-1
s(169) =< s(166)
s(170) =< s(167)*s(168)
s(171) =< s(167)*s(169)
s(172) =< s(167)*s(165)
s(173) =< s(167)*s(169)
s(174) =< s(170)
s(175) =< s(166)
s(175) =< s(171)
s(176) =< s(175)*s(165)
s(177) =< s(175)*s(166)
s(154) =< aux(33)
s(155) =< aux(33)
s(155) =< aux(32)
s(156) =< s(155)*aux(33)
s(157) =< s(155)*aux(32)
s(188) =< aux(33)
s(189) =< aux(32)-2
s(190) =< aux(32)
s(191) =< s(186)*s(188)
s(192) =< s(186)*s(189)
s(193) =< s(186)*s(190)
s(194) =< s(192)
s(195) =< s(191)
s(195) =< s(193)
s(196) =< s(195)*aux(33)
s(197) =< s(195)*aux(32)
s(208) =< s(150)*s(188)
s(209) =< s(150)*s(189)
s(210) =< s(150)*s(190)
s(211) =< s(209)
s(212) =< s(208)
s(212) =< s(210)
s(213) =< s(212)*aux(33)
s(214) =< s(212)*aux(32)
with precondition: [V>=0]
* Chain [31]: 1
with precondition: [V1=0,V>=0]
* Chain [30]: 6*s(218)+2*s(220)+5*s(221)+5*s(222)+5*s(223)+3
Such that:s(215) =< 1
aux(34) =< V+1
s(218) =< aux(34)
s(220) =< s(215)
s(221) =< s(215)
s(221) =< aux(34)
s(222) =< s(221)*s(215)
s(223) =< s(221)*aux(34)
with precondition: [V1=1,V>=1]
Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [32] with precondition: [V>=0]
- Upper bound: 12*V+3+16*V*nat(V1)+nat(V1)*V*V+V/2*V*nat(V1)+nat(V1)*22+nat(V1)*V+nat(V1)*16*nat(V1)+nat(V1)*nat(V1)*V+V/2*nat(V1)*nat(V1)+nat(V-2)*2*V+V/2* (nat(V-2)*2)+nat(nat(V+V1)+ -1)*4*nat(V+V1)+nat(V+V1)*44+nat(V+V1)*12*nat(V+V1)+3/2*V+V/2*nat(V1)
- Complexity: n^3
* Chain [31] with precondition: [V1=0,V>=0]
- Upper bound: 1
- Complexity: constant
* Chain [30] with precondition: [V1=1,V>=1]
- Upper bound: 11*V+26
- Complexity: n
### Maximum cost of start(V,V1): max([11*V+25,12*V+2+16*V*nat(V1)+nat(V1)*V*V+V/2*V*nat(V1)+nat(V1)*22+nat(V1)*V+nat(V1)*16*nat(V1)+nat(V1)*nat(V1)*V+V/2*nat(V1)*nat(V1)+nat(V-2)*2*V+V/2* (nat(V-2)*2)+nat(nat(V+V1)+ -1)*4*nat(V+V1)+nat(V+V1)*44+nat(V+V1)*12*nat(V+V1)+3/2*V+V/2*nat(V1)])+1
Asymptotic class: n^3
* Total analysis performed in 497 ms.